import { Switch } from "antd";
import { useSelector, useDispatch } from "react-redux";
import { changeTheme } from "@/redux/globalSlice";
const SwitchDark = (props: any) => {
  const { setThemeConfig, themeConfig } = props;
  const them = useSelector((state: any) => state.global.theme);
  const dispatch = useDispatch();
  const onChange = (checked: boolean) => {
    if (them === "default") {
      dispatch(changeTheme("dark"));
    } else {
      dispatch(changeTheme("default"));
    }
  };

  return (
    <Switch
      className='dark'
      defaultChecked='dark'
      checkedChildren={<>🌞</>}
      unCheckedChildren={<>🌜</>}
      onChange={onChange}
    />
  );
};

export default SwitchDark;
